/* 
 * File:   DescriptorReader.cpp
 * Author: max
 * 
 * Created on April 3, 2013, 11:41 PM
 */

#include <sstream>
#include <vector>
#include "common_Descriptor.h"

using namespace TP;

Descriptor::Descriptor(char delimiter) {
    _delimiter = delimiter;
}

Descriptor::~Descriptor() {
    _params.clear();
}

string& Descriptor::parse(const string &pString){

    std::stringstream strm (pString);
    string chunk = "";
    
    while (!strm.eof())
    {
        std::getline (strm, chunk, this->_delimiter);
        _params.push_back(chunk);
    }
    return _params[0];
}

string& Descriptor::data(uint32_t pIndex) throw (IndiceFueraRangoExcepcion&){
    
    if (0 <= pIndex && pIndex < _params.size())
        return _params[pIndex];
    else
        throw IndiceFueraRangoExcepcion ("Indice fuera de rango.");
    
}

